package es.dk.hl.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import es.dk.hl.business.PhotoDelegate;
	import es.dk.hl.event.PhotoEvent;
	import es.dk.hl.model.HomeLinkModelLocator;
	
	import mx.collections.XMLListCollection;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	
	public class Photo_Get_Command implements ICommand, IResponder
	{
		public var eventQuery:PhotoEvent;
		
		public function execute(event:CairngormEvent):void
		{
			eventQuery = PhotoEvent(event);
			new PhotoDelegate(this).Photo_Get(eventQuery.photo);
		}
		
		public function result(data:Object):void
		{
			var xmlList:XMLList = XMLList(ResultEvent(data).result.photo.(@type==eventQuery.photo.photoType))
			var xmlListCollection:XMLListCollection = new XMLListCollection(xmlList);					
			HomeLinkModelLocator.getInstance().photoXLC = xmlListCollection;
		}
		
		public function fault(info:Object):void
		{
			trace(info);
		}
	}
}